import React, { Suspense } from 'react'
import { Route, Routes, BrowserRouter, Navigate } from 'react-router-dom'
import mainRouter from './Router_config'
type Props = {}
function Router_Viwe({ }: Props) {
    const Reactindex = (arr: any) => {
        return arr.map((item: any, index: number) => {
            return <Route key={index} path={item.path} element={item.element ? <item.element></item.element> : <Navigate to={item.to}></Navigate>}>
                {
                    item.children && Reactindex(item.children)
                }
            </Route>
        })
    }
    return (
        <>
            <Suspense fallback={<>加载中....</>}>
                <BrowserRouter>
                    <Routes>
                        {
                            Reactindex(mainRouter)
                        }
                    </Routes>
                </BrowserRouter>
            </Suspense>
        </>
    )
}

export default Router_Viwe